package com.xm.servlet.background.commodity;

import com.google.gson.Gson;
import com.xm.service.background.CategoryService;
import lombok.SneakyThrows;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 根据类别查询
 * @author 康文程
 * @date 2024-1-20 下午 02:22
 */
@WebServlet("/background/get/find/category/by/model/id")
public class GetFindCategoryByModelIdServlet extends HttpServlet {
    private final CategoryService service = new CategoryService();
    @SneakyThrows
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
        resp.setContentType("text/html;charset=UTF-8");
        String modelId = req.getParameter("modelId");
        resp.getWriter().print(new Gson().toJson(service.findCategoryByModelId(Integer.parseInt(modelId))));
    }
}
